package com.ruoyi.common.core.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * web层通用数据处理
 * 
 * @author ruoyi
 */
public class PrefixController extends BaseController {
	
	protected String prefix = null;

	public PrefixController() {
		prefix = getAnnoPrefix();
	}

	public String getAnnoPrefix() {
		RequestMapping annotation = this.getClass().getAnnotation(RequestMapping.class);
		String[] ar = annotation.value();
		return ar.length >0 ? ar[0] : "";
	}
	
	public boolean isPermitted(String url) throws Exception {
		Subject subject = SecurityUtils.getSubject();
		if (subject.isPermitted(url)){
			return true;
		} else {
			return false;
		}
	}
	
	public void tryPermitted(String url) throws Exception {
//		if (!this.isPermitted(url)){
//			throw new Exception("当前用户无权限操作");
//		}
	}

}
